# encoding: UTF-8

class Admin::ManualsController < ApplicationController

  before_filter :user_signed_in?
  
  def index
    @manuals = Manual.all
    set_seo_meta '玩家手册'
  end

  def new
    set_seo_meta '玩家手册添加'
  end

  def create
    @manual = Manual.new(params[:session])
    if @manual.save
      redirect_to manuals_path, notice: '新增成功'
    else
      redirect_referrer_or_default
    end  
  end

  def edit
    @manual = Manual.find(params[:id])
    set_seo_meta '玩家手册修改'
  end

  def update
    @manual = Manual.find(params[:id])
    if @manual.update_attributes(params[:session])
      redirect_to manuals_path, notice: '修改成功'
    else
      redirect_referrer_or_defautl default
    end
  end

  def destroy
    if Manual.delete(params[:id])
      redirect_to manuals_path, notice: '删除成功'
    else
      redirect_referrer_or_default default
    end  
  end

end
